package com.example.controller;

import com.example.entity.EduTeacher;
import com.example.service.TeacherServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/providers")
public class Provider {

    @Value("${sb}")
    public String datasource;

    @GetMapping(value = {"/provider/{username}/{age}",
            "/provider/{username}",
            "/provider"})
    public String provider(@PathVariable(value = "username", required = false) String username,
                           @PathVariable(value = "age", required = false) Integer age) {
        return "provider" + "===>年龄" + age + "===>名字" + username+"datasource==>"+datasource;
    }

    @Autowired
    private TeacherServiceImpl teacherService;

    @GetMapping("/teachers")
    public String teachers() {
        List<EduTeacher> teachers = teacherService.teachers();
        return "O(∩_∩)O😄";
    }

    @GetMapping("/streamtest/{msg}/{msg1}")
    public void streamSendMsg(@PathVariable("msg") String msg,@PathVariable("msg1") String msg1){
        teacherService.produceMessage(msg,msg1);
    }

}
